using System;
using TMPro;
using UnityEngine;

namespace CardGameObject.PackageStoreScene
{
    public class StorePackage: MonoBehaviour
    {
        private int Id { get; set; }
        private string Name { get; set; }
        private int Price { get; set; }
        private int CardCount { get; set; }
        
        public TextMeshPro NameText;
        public TextMeshPro PriceText;
        public SpriteRenderer PackageImage;
        public SpriteRenderer PackageBorder;

        private PackageManager packageManager;
        
        public void SetPackageInfo(int packageId, string packageName , int packagePrice)
        {
            Id = packageId;
            Name = packageName;
            Price = packagePrice;

            NameText.text = packageName;
            PriceText.text = Price.ToString();
            
            Sprite sprite = Resources.Load<Sprite>($"Images/PackageImage/Content/{packageName}");
            if (sprite != null)
            {
                PackageImage.sprite = sprite;
            }
        }

        public void OnMouseDown()
        {
            packageManager = PackageManager.GetInstance();
            packageManager.SetCurPurchasePackage(gameObject , Id);
        }
        
        /// <summary>
        /// 设置边框颜色为绿色并显示边框
        /// </summary>
        public void SetSelectedBorder()
        {
            Color greenColor = Color.green;
            greenColor.a = 1f; // 设置透明度为完全不透明
            PackageBorder.color = greenColor;
        }

        /// <summary>
        /// 设置边框透明，使其不再显示
        /// </summary>
        public void SetBorderTransparent()
        {
            Color transparentColor = PackageBorder.color;
            transparentColor.a = 0f; // 设置透明度为完全透明
            PackageBorder.color = transparentColor;
        }
    }
}